package com.alix.paymoney.presenter.impl;

import com.alix.paymoney.entity.DataBean;
import com.alix.paymoney.http.CallManager;
import com.alix.paymoney.http.HttpManager;
import com.alix.paymoney.http.OnResponseListener;
import com.alix.paymoney.http.request.RecordRequest;
import com.alix.paymoney.presenter.ChannelRecordPresenter;
import com.alix.paymoney.utils.Loger;
import com.alix.paymoney.view.ChannelRecordView;

import retrofit2.Call;

/**
 * Created by wushiqian on 2017/11/14.
 */

public class ChannelRecordPresenterImpl extends BasePresenterImpl<ChannelRecordView> implements ChannelRecordPresenter {
    public ChannelRecordPresenterImpl(ChannelRecordView channelRecordView) {
        super(channelRecordView);
    }

    @Override
    public void getChannelRecord(String channelId, String token) {
        RecordRequest recordRequest=new RecordRequest();
        recordRequest.setChannelId(channelId);
        recordRequest.setToken(token);

        Call<DataBean> channelRecord = HttpManager.getInstance().getApiService().getChannelRecord(channelId,token);
        CallManager.getInstance().addQueue(channelRecord, new OnResponseListener<DataBean>() {
            @Override
            public void Success(DataBean o) {
                getView().getChannelRecordSuccess(o.getData());
            }

            @Override
            public void onFailed(int errorCode, String errorInfo) {
                getView().getChannelRecordError(errorCode,errorInfo);
                Loger.e(errorCode+"频道记录"+errorInfo);
            }

            @Override
            public void onException(String msg) {
                Loger.e("频道记录"+msg);
                getView().showTips(msg);
            }
        });
    }
}
